package demo15;

import java.util.ArrayList;
import java.util.List;

//T extends Comparable<T>  T一定要实现comparable接口
class Ajg/*<T extends Comparable<T>>*/{
    //静态泛型方法
    public static <T extends Comparable<T>> T findMax(T[] array) {
        T max = array[0];
        for (int i = 0; i < array.length; i++) {
            //max < array[i] error
            if (array[i].compareTo(max) > 0) {
                max = array[i];
            }
        }
        return max;
    }
}
class A implements Comparable<A> {
    @Override
    public int compareTo(A o) {
        return 0;
    }
}

public class Test15 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
    }
    public static void main1(String[] args) {
        Integer[] integers = new Integer[]{1,2,45,67,1,23};
        System.out.println(Ajg.findMax(integers));
    }
}
